package com.clstu.staticmathod_.abstrac_;

public class Abstract {
    public static void main(String[] args) {
      new Worker("jack","20202020",20000).work();
      new Manager("mry","20202021",20000,12000).work();

    }
}
abstract class Employee{
    private String name;
    private String id;
    private double sal;

    public abstract void work();  //非抽象方法必须要有方法体

    public String getName() {
        return name;
    }

    public Employee(String name, String id, double sal) {//这里最后有一个构造函数，虽然用不到，但是子类能用super调用，提高代码复用性
        this.name = name;
        this.id = id;
        this.sal = sal;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }
}

class Worker extends Employee{
    public Worker(String name, String id, double sal) {
        super(name, id, sal);
    }

    @Override
    public void work() {
        System.out.println("Worker "+getName()+" is working ...");

    }
}

class Manager extends Employee{
    private double bonus;

    public Manager(String name, String id, double sal, double bonus) {
        super(name, id, sal);
        this.bonus = bonus;
    }

    @Override
    public void work() {
        System.out.println("Worker "+getName()+" is working ...");
    }
}